
var data = [
    {
      id: 1,
      field1: 'qqqqqqq',
      field2: '222',
      field3: '333',
      field4: '222',
    },
    {
      id: 2,
      field1: 'wwwwwwww',
      field2: '222',
      field3: '333',
      field4: '222',
    },
    {
      id: 3,
      field1: 'eeeeeeeeeeeee',
      field2: '222',
      field3: '333',
      field4: '222',
    },
    {
      id: 4,
      field1: 'rrrrrrrrrrrrrrrrrrrrr',
      field2: '222',
      field3: '333',
      field4: '222',
    }
];

var data1 = [
  {
    id: 1,
    field1: '2014.09.10',
    field2: '正常',
    field3: '张三',
    field4: '2014.10.10',
    field5: 'G220公路工程',
    field6: '李四',
    field7: '2014.10.10',
    field8: '正常',
    field9: '工程使用',
  },
];

var data2 = [
  {
    id: 1,
    field1: '2014.09.10',
    field2: 'G220公路工程',
    field3: '电源短路',
    field4: '维修',
    field5: '半年',
    field6: '1000',
    field7: '工程使用',
  },
];

var data3 = [
  {
    id: 1,
    field1: '2014.09.10',
    field2: '质量部',
    field3: 'G220公路工程',
    field4: '工程使用',
    field5: '',
  },
];

/**
 * 根据条件查询
 */
function queryByCondition() {
    var param = {};
    $('#table1').bootstrapTable('refreshOptions', {
      queryParams: function (params) {
          var obj = {
            size: params.limit,
            page: params.offset / params.limit + 1,
          };
          $.extend(param, obj);
          return JSON.stringify(param);
      }
    });
};

/**
 * 表格初始化
 */
function initTable(newParams) {
  var $table = $('#table1');
  $table.bootstrapTable({
    url: "",
    method: 'POST',
    pagination: true,
    pageSize: 10,
    sidePagination: 'server',//设置为服务器端分页
    queryParams: function (params) {
      // 请求参数
      var obj = {
        size: params.limit,
        page: params.offset / params.limit + 1
      };
      return JSON.stringify(obj);
    }
  });
};

$(document).ready(function() {
    var $table = $('#table1');
    $table.bootstrapTable({
      data: data1,
      pagination: true
    });

    var $table = $('#table2');
    $table.bootstrapTable({
      data: data2,
      pagination: true
    });

     var $table = $('#table3');
    $table.bootstrapTable({
      data: data3,
      pagination: true
    });

    initNavTab(function(index){
      console.log(index);
    });
});
